/*
 * Copyright (C) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Auto-generated C bindings for user_auth_rs
 * Generated by cbindgen from Rust FFI definitions
 */

#include <stdint.h>
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif


#ifndef USER_AUTH_FFI_H
#define USER_AUTH_FFI_H

#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

#define PUBLIC_KEY_LEN_FFI 32

#define CHALLENGE_LEN_FFI 32

#define UDID_LEN_FFI 64

#define ROOT_SECRET_LEN_FFI 32

#define MAX_EVENT_NUM_FFI 20

#define MAX_AUTH_TOKEN_LEN_FFI 1024

#define MAX_CREDENTIAL_NUM_FFI 32

#define MAX_EXECUTOR_NUM_FFI 32

#define MAX_MSG_LEN_FFI 1024

#define MAX_SCHEDULE_NUM_FFI 2

#define MAX_TEMPLATE_ID_NUM_FFI 32

#define MAX_USER_NUM_FFI 6

#define MAX_LONG_C_STRING_LEN_FFI 200

#define MAX_C_STRING_LEN_FFI 50

enum CommandId {
  INIT = 1,
  ADD_EXECUTOR = 2,
  DELETE_EXECUTOR = 3,
  OPEN_SESSION = 4,
  CLOSE_SESSION = 5,
  UPDATE_ENROLLMENT_RESULT = 6,
  CANCEL_ENROLLMENT = 7,
  DELETE_CREDENTIAL = 8,
  GET_CREDENTIAL = 9,
  GET_USER_INFO = 10,
  DELETE_USER = 11,
  ENFORCE_DELETE_USER = 12,
  UPDATE_AUTHENTICATION_RESULT = 13,
  CANCEL_AUTHENTICATION = 14,
  GET_AVAILABLE_STATUS = 15,
  GET_VALID_SOLUTION = 16,
  BEGIN_AUTHENTICATION = 17,
  BEGIN_ENROLLMENT = 18,
  GET_ALL_USER_INFO = 19,
  GET_ALL_EXT_USER_INFO = 20,
  GET_ENROLLED_STATE = 21,
  CHECK_REUSE_UNLOCK_RESULT = 22,
  SEND_MESSAGE = 23,
  PREPARE_REMOTE_AUTH = 24,
  GET_LOCAL_SCHEDULE_FROM_MESSAGE = 25,
  GET_SIGNED_EXECUTOR_INFO = 26,
  GET_AUTH_RESULT_FROM_MESSAGE = 27,
  SET_GLOBAL_CONFIG_PARAM = 28,
  GET_CREDENTIAL_BY_ID = 29,
  VERIFY_AUTH_TOKEN = 30,
  UPDATE_ABANDON_RESULT = 31,
  CLEAR_UNAVAILABLE_CREDENTIAL = 32,
};
typedef int32_t CommandId;

typedef struct RustCommandParam {
  int32_t commandId;
  const uint8_t *inputData;
  uint32_t inputDataLen;
  uint8_t *outputData;
  uint32_t outputDataLen;
  uint8_t *commonOutputData;
  uint32_t commonOutputDataLen;
} RustCommandParam;

typedef struct AuthTokenArrayFfi {
  uint8_t data[MAX_AUTH_TOKEN_LEN_FFI];
  uint32_t len;
} AuthTokenArrayFfi;

typedef struct MessageArrayFfi {
  uint8_t data[MAX_MSG_LEN_FFI];
  uint32_t len;
} MessageArrayFfi;

typedef struct TemplateIdArrayFfi {
  uint64_t data[MAX_TEMPLATE_ID_NUM_FFI];
  uint32_t len;
} TemplateIdArrayFfi;

typedef struct ExecutorIndexArrayFfi {
  uint64_t data[MAX_EXECUTOR_NUM_FFI];
  uint32_t len;
} ExecutorIndexArrayFfi;

typedef struct UserIdArrayFfi {
  int32_t data[MAX_USER_NUM_FFI];
  uint32_t len;
} UserIdArrayFfi;

typedef struct Int32ArrayFfi {
  int32_t data[MAX_CREDENTIAL_NUM_FFI];
  uint32_t len;
} Int32ArrayFfi;

typedef struct PlaceHolderFfi {
  uint8_t placeHolder;
} PlaceHolderFfi;

typedef struct CStringFfi {
  uint8_t data[MAX_C_STRING_LEN_FFI];
  uint32_t len;
} CStringFfi;

typedef struct LongCStringFfi {
  uint8_t data[MAX_LONG_C_STRING_LEN_FFI];
  uint32_t len;
} LongCStringFfi;

typedef struct EventFfi {
  uint64_t time;
  struct CStringFfi fileName;
  uint32_t lineNumber;
  int32_t eventType;
  struct LongCStringFfi eventInfo;
} EventFfi;

typedef struct EventArrayFfi {
  struct EventFfi data[MAX_EVENT_NUM_FFI];
  uint32_t len;
} EventArrayFfi;

typedef struct CommonOutputFfi {
  int32_t result;
  bool hasFatalError;
  struct EventArrayFfi events;
} CommonOutputFfi;

typedef struct EnrolledInfoFfi {
  uint64_t enrolledId;
  int32_t authType;
} EnrolledInfoFfi;

typedef struct EnrolledInfoArrayFfi {
  struct EnrolledInfoFfi data[MAX_CREDENTIAL_NUM_FFI];
  uint32_t len;
} EnrolledInfoArrayFfi;

typedef struct UserInfoFfi {
  uint64_t secureUid;
  int32_t pinSubType;
  struct EnrolledInfoArrayFfi enrolledInfos;
} UserInfoFfi;

typedef struct UserInfoArrayFfi {
  struct UserInfoFfi data[MAX_USER_NUM_FFI];
  uint32_t len;
} UserInfoArrayFfi;

typedef struct ExtUserInfoFfi {
  int32_t userId;
  struct UserInfoFfi userInfo;
} ExtUserInfoFfi;

typedef struct ExtUserInfoArrayFfi {
  struct ExtUserInfoFfi data[MAX_USER_NUM_FFI];
  uint32_t len;
} ExtUserInfoArrayFfi;

typedef struct CredentialInfoFfi {
  uint64_t credentialId;
  uint64_t executorIndex;
  uint64_t templateId;
  int32_t authType;
  uint32_t executorMatcher;
  uint32_t executorSensorHint;
  int32_t authSubType;
  uint8_t isAbandoned;
  int64_t validityPeriod;
} CredentialInfoFfi;

typedef struct CredentialArrayFfi {
  struct CredentialInfoFfi data[MAX_CREDENTIAL_NUM_FFI];
  uint32_t len;
} CredentialArrayFfi;

typedef struct ExecutorSendMsgFfi {
  uint64_t executorIndex;
  int32_t commandId;
  struct MessageArrayFfi msg;
} ExecutorSendMsgFfi;

typedef struct ExecutorSendMsgArrayFfi {
  struct ExecutorSendMsgFfi data[MAX_EXECUTOR_NUM_FFI];
  uint32_t len;
} ExecutorSendMsgArrayFfi;

typedef struct AuthResultInfoFfi {
  int32_t result;
  int32_t lockoutDuration;
  int32_t remainAttempts;
  struct ExecutorSendMsgArrayFfi msgs;
  struct AuthTokenArrayFfi token;
  struct MessageArrayFfi rootSecret;
  int32_t userId;
  uint64_t credentialId;
  int64_t pinExpiredInfo;
  struct MessageArrayFfi remoteAuthResultMsg;
  uint8_t reEnrollFlag;
} AuthResultInfoFfi;

typedef struct EnrolledStateFfi {
  uint64_t credentialDigest;
  uint16_t credentialCount;
} EnrolledStateFfi;

typedef struct ScheduleInfoFfi {
  uint64_t scheduleId;
  struct TemplateIdArrayFfi templateIds;
  int32_t authType;
  uint32_t executorMatcher;
  int32_t scheduleMode;
  struct ExecutorIndexArrayFfi executorIndexes;
  struct MessageArrayFfi executorMessages[MAX_EXECUTOR_NUM_FFI];
  uint32_t executorMessageCount;
} ScheduleInfoFfi;

typedef struct ScheduleInfoArrayFfi {
  struct ScheduleInfoFfi data[MAX_SCHEDULE_NUM_FFI];
  uint32_t len;
} ScheduleInfoArrayFfi;

typedef struct InitInputFfi {
  uint8_t deviceUdid[UDID_LEN_FFI];
} InitInputFfi;

typedef struct PlaceHolderFfi InitOutputFfi;

typedef struct ExecutorRegisterInfoFfi {
  int32_t authType;
  int32_t executorRole;
  uint32_t executorSensorHint;
  uint32_t executorMatcher;
  int32_t esl;
  int32_t maxTemplateAcl;
  uint8_t publicKey[PUBLIC_KEY_LEN_FFI];
  uint8_t deviceUdid[UDID_LEN_FFI];
  struct MessageArrayFfi signedRemoteExecutorInfo;
} ExecutorRegisterInfoFfi;

typedef struct AddExecutorInputFfi {
  struct ExecutorRegisterInfoFfi info;
} AddExecutorInputFfi;

typedef struct AddExecutorOutputFfi {
  uint64_t index;
  uint8_t publicKey[PUBLIC_KEY_LEN_FFI];
  struct TemplateIdArrayFfi templateIds;
} AddExecutorOutputFfi;

typedef struct DeleteExecutorInputFfi {
  uint64_t index;
} DeleteExecutorInputFfi;

typedef struct PlaceHolderFfi DeleteExecutorOutputFfi;

typedef struct OpenSessionInputFfi {
  int32_t userId;
} OpenSessionInputFfi;

typedef struct OpenSessionOutputFfi {
  uint8_t challenge[CHALLENGE_LEN_FFI];
} OpenSessionOutputFfi;

typedef struct CloseSessionInputFfi {
  int32_t userId;
} CloseSessionInputFfi;

typedef struct PlaceHolderFfi CloseSessionOutputFfi;

typedef struct UpdateEnrollmentResultInputFfi {
  int32_t userId;
  struct MessageArrayFfi scheduleResult;
} UpdateEnrollmentResultInputFfi;

typedef struct EnrollResultInfoFfi {
  uint64_t credentialId;
  struct CredentialInfoFfi oldInfo;
  uint8_t rootSecret[ROOT_SECRET_LEN_FFI];
  uint8_t oldRootSecret[ROOT_SECRET_LEN_FFI];
  struct AuthTokenArrayFfi authToken;
} EnrollResultInfoFfi;

typedef struct UpdateEnrollmentResultOutputFfi {
  struct EnrollResultInfoFfi info;
} UpdateEnrollmentResultOutputFfi;

typedef struct CancelEnrollmentInputFfi {
  int32_t userId;
} CancelEnrollmentInputFfi;

typedef struct PlaceHolderFfi CancelEnrollmentOutputFfi;

typedef struct DeleteCredentialInputFfi {
  int32_t userId;
  uint64_t credentialId;
  struct AuthTokenArrayFfi authToken;
} DeleteCredentialInputFfi;

typedef struct DeleteCredentialOutputFfi {
  int32_t operateType;
  struct ScheduleInfoFfi scheduleInfo;
  struct CredentialArrayFfi credentialInfos;
} DeleteCredentialOutputFfi;

typedef struct GetCredentialInputFfi {
  int32_t userId;
  int32_t authType;
} GetCredentialInputFfi;

typedef struct GetCredentialOutputFfi {
  struct CredentialArrayFfi infos;
} GetCredentialOutputFfi;

typedef struct GetUserInfoInputFfi {
  int32_t userId;
} GetUserInfoInputFfi;

typedef struct GetUserInfoOutputFfi {
  uint64_t secureUid;
  int32_t pinSubType;
  struct EnrolledInfoArrayFfi infos;
} GetUserInfoOutputFfi;

typedef struct DeleteUserInputFfi {
  int32_t userId;
  struct AuthTokenArrayFfi authToken;
} DeleteUserInputFfi;

typedef struct DeleteUserOutputFfi {
  struct CredentialArrayFfi deletedInfos;
  uint8_t rootSecret[ROOT_SECRET_LEN_FFI];
} DeleteUserOutputFfi;

typedef struct EnforceDeleteUserInputFfi {
  int32_t userId;
} EnforceDeleteUserInputFfi;

typedef struct EnforceDeleteUserOutputFfi {
  struct CredentialArrayFfi deletedInfos;
} EnforceDeleteUserOutputFfi;

typedef struct UpdateAuthenticationResultInputFfi {
  uint64_t contextId;
  struct MessageArrayFfi scheduleResult;
} UpdateAuthenticationResultInputFfi;

typedef struct UpdateAuthenticationResultOutputFfi {
  struct AuthResultInfoFfi info;
  struct EnrolledStateFfi enrolledState;
} UpdateAuthenticationResultOutputFfi;

typedef struct CancelAuthenticationInputFfi {
  uint64_t contextId;
} CancelAuthenticationInputFfi;

typedef struct PlaceHolderFfi CancelAuthenticationOutputFfi;

typedef struct GetAvailableStatusInputFfi {
  int32_t userId;
  int32_t authType;
  int32_t authTrustLevel;
} GetAvailableStatusInputFfi;

typedef struct PlaceHolderFfi GetAvailableStatusOutputFfi;

typedef struct GetValidSolutionInputFfi {
  int32_t userId;
  struct Int32ArrayFfi authTypes;
  int32_t authTrustLevel;
} GetValidSolutionInputFfi;

typedef struct GetValidSolutionOutputFfi {
  struct Int32ArrayFfi validTypes;
} GetValidSolutionOutputFfi;

typedef struct AuthParamBaseFfi {
  int32_t userId;
  int32_t authTrustLevel;
  uint32_t executorSensorHint;
  uint8_t challenge[CHALLENGE_LEN_FFI];
} AuthParamBaseFfi;

typedef struct AuthParamFfi {
  struct AuthParamBaseFfi baseParam;
  int32_t authType;
  int32_t authIntent;
  uint8_t isOsAccountVerified;
  uint8_t collectorUdid[UDID_LEN_FFI];
} AuthParamFfi;

typedef struct BeginAuthenticationInputFfi {
  uint64_t contextId;
  struct AuthParamFfi param;
} BeginAuthenticationInputFfi;

typedef struct BeginAuthenticationOutputFfi {
  struct ScheduleInfoArrayFfi scheduleInfos;
} BeginAuthenticationOutputFfi;

typedef struct EnrollParamFfi {
  int32_t authType;
  uint32_t executorSensorHint;
  int32_t userId;
  int32_t userType;
  int32_t authSubType;
} EnrollParamFfi;

typedef struct BeginEnrollmentInputFfi {
  struct AuthTokenArrayFfi authToken;
  struct EnrollParamFfi param;
} BeginEnrollmentInputFfi;

typedef struct BeginEnrollmentOutputFfi {
  struct ScheduleInfoFfi info;
} BeginEnrollmentOutputFfi;

typedef struct PlaceHolderFfi GetAllUserInfoInputFfi;

typedef struct GetAllUserInfoOutputFfi {
  struct UserInfoArrayFfi userInfos;
} GetAllUserInfoOutputFfi;

typedef struct PlaceHolderFfi GetAllExtUserInfoInputFfi;

typedef struct GetAllExtUserInfoOutputFfi {
  struct ExtUserInfoArrayFfi userInfos;
} GetAllExtUserInfoOutputFfi;

typedef struct GetEnrolledStateInputFfi {
  int32_t userId;
  int32_t authType;
} GetEnrolledStateInputFfi;

typedef struct GetEnrolledStateOutputFfi {
  struct EnrolledStateFfi enrolledState;
} GetEnrolledStateOutputFfi;

typedef struct ReuseUnlockParamFfi {
  struct AuthParamBaseFfi baseParam;
  struct Int32ArrayFfi authTypes;
  uint64_t reuseUnlockResultDuration;
  int32_t reuseUnlockResultMode;
} ReuseUnlockParamFfi;

typedef struct ReuseUnlockInfoFfi {
  int32_t authType;
  struct AuthTokenArrayFfi token;
  struct EnrolledStateFfi enrolledState;
} ReuseUnlockInfoFfi;

typedef struct CheckReuseUnlockResultInputFfi {
  struct ReuseUnlockParamFfi reuseParam;
} CheckReuseUnlockResultInputFfi;

typedef struct CheckReuseUnlockResultOutputFfi {
  struct ReuseUnlockInfoFfi reuseInfo;
} CheckReuseUnlockResultOutputFfi;

typedef struct PrepareRemoteAuthInputFfi {
  uint8_t remoteUdid[UDID_LEN_FFI];
} PrepareRemoteAuthInputFfi;

typedef struct PlaceHolderFfi PrepareRemoteAuthOutputFfi;

typedef struct GetLocalScheduleFromMessageInputFfi {
  uint8_t remoteUdid[UDID_LEN_FFI];
  struct MessageArrayFfi message;
} GetLocalScheduleFromMessageInputFfi;

typedef struct GetLocalScheduleFromMessageOutputFfi {
  struct ScheduleInfoFfi scheduleInfo;
} GetLocalScheduleFromMessageOutputFfi;

typedef struct GetSignedExecutorInfoInputFfi {
  struct Int32ArrayFfi authTypes;
  int32_t executorRole;
  uint8_t remoteUdid[UDID_LEN_FFI];
} GetSignedExecutorInfoInputFfi;

typedef struct GetSignedExecutorInfoOutputFfi {
  struct MessageArrayFfi signedExecutorInfo;
} GetSignedExecutorInfoOutputFfi;

typedef struct GetAuthResultFromMessageInputFfi {
  uint8_t remoteUdid[UDID_LEN_FFI];
  struct MessageArrayFfi message;
} GetAuthResultFromMessageInputFfi;

typedef struct GetAuthResultFromMessageOutputFfi {
  struct AuthResultInfoFfi authResultInfo;
} GetAuthResultFromMessageOutputFfi;

typedef struct GlobalConfigParamFfi {
  int32_t type;
  int64_t pinExpiredPeriod;
  uint8_t enableStatus;
  struct Int32ArrayFfi userIds;
  struct Int32ArrayFfi authTypes;
} GlobalConfigParamFfi;

typedef struct SetGlobalConfigParamInputFfi {
  struct GlobalConfigParamFfi param;
} SetGlobalConfigParamInputFfi;

typedef struct PlaceHolderFfi SetGlobalConfigParamOutputFfi;

typedef struct GetCredentialByIdInputFfi {
  uint64_t credentialId;
} GetCredentialByIdInputFfi;

typedef struct GetCredentialByIdOutputFfi {
  struct CredentialInfoFfi info;
} GetCredentialByIdOutputFfi;

typedef struct VerifyAuthTokenInputFfi {
  struct AuthTokenArrayFfi tokenIn;
  uint64_t allowableDuration;
} VerifyAuthTokenInputFfi;

typedef struct VerifyAuthTokenOutputFfi {
  uint32_t version;
  int32_t userId;
  uint8_t challenge[CHALLENGE_LEN_FFI];
  uint64_t timeInterval;
  int32_t authTrustLevel;
  int32_t authType;
  int32_t authMode;
  uint32_t securityLevel;
  int32_t tokenType;
  uint64_t secureUid;
  uint64_t enrolledId;
  uint64_t credentialId;
  uint8_t collectorUdid[UDID_LEN_FFI];
  uint8_t verifierUdid[UDID_LEN_FFI];
  uint8_t rootSecret[ROOT_SECRET_LEN_FFI];
} VerifyAuthTokenOutputFfi;

typedef struct UpdateAbandonResultInputFfi {
  int32_t userId;
  struct MessageArrayFfi scheduleResult;
} UpdateAbandonResultInputFfi;

typedef struct UpdateAbandonResultOutputFfi {
  struct CredentialArrayFfi infos;
} UpdateAbandonResultOutputFfi;

typedef struct ClearUnavailableCredentialInputFfi {
  struct UserIdArrayFfi userIds;
} ClearUnavailableCredentialInputFfi;

typedef struct ClearUnavailableCredentialOutputFfi {
  struct CredentialArrayFfi credentials;
} ClearUnavailableCredentialOutputFfi;

int32_t init_rust_env(void);

int32_t uninit_rust_env(void);

int32_t invoke_rust_command(struct RustCommandParam Param);

#endif  /* USER_AUTH_FFI_H */

#ifdef __cplusplus
}
#endif
